<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-song-edit" th:object="${song}">
            <input id="songId" name="songId" th:field="*{songId}"  type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">歌曲名称：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="songName" id="songName" th:field="*{songName}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">级别：</label>
                <div class="col-sm-8">
                    <select id="level" class="form-control m-b" th:with="type=${@dict.getType('zl_subject_level')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{level}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">星级：</label>
                <div class="col-sm-8">
                    <select id="starLevel" class="form-control m-b" th:with="type=${@dict.getType('zl_song_xingji')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{starLevel}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">参考课时费：</label>
                <div class="col-sm-8">
                    <input id="teacherCost" name="teacherCost" th:field="*{teacherCost}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="remark" name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "project/song"
		$("#form-song-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});

        function submitHandler() {
            if ($.validate.form()) {
                edit();
            }
        }

        function edit() {

            var songId = $("input[name='songId']").val();
            var songName = $("input[name='songName']").val();
            var level = $("#level option:selected").val();
            var starLevel = $("#starLevel option:selected").val();
            var teacherCost = $("input[name='teacherCost']").val();
            var remark =$("input[name='remark']").val();


            $.ajax({
                cache : true,
                type : "POST",
                url : ctx + "project/song/edit",
                data : {
                    "songId": songId,
                    "songName": songName,
                    "level": level,
                    "starLevel": starLevel,
                    "teacherCost": teacherCost,
                    "remark": remark

                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.saveSuccess(data);
                }
            });
        }
	</script>
</body>
</html>
